import 'package:flutter/material.dart';

// ignore: must_be_immutable
class MyDialog extends Dialog {
  String title;

  MyDialog({Key? key, this.title = '提示'}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    // 返回 Material组件
    return Material(
      type: MaterialType.transparency, // 透明背景
      // 包裹Center组件
      child: Center(
        child: Container(
          width: 300,
          height: 200,
          color: Colors.amber,
          child: Column(
            children: [
              Text(title),
              const Text('提示内容'),
              TextButton(
                onPressed: () {
                  Navigator.pop(context);
                  print('确定');
                },
                child: const Text('确定'),
              ),
              TextButton(
                onPressed: () {
                  Navigator.pop(context);
                  print('取消');
                },
                child: const Text('取消'),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
